<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>整数转罗马数字 | Freeisms</title>
    <meta name="generator" content="VuePress 1.7.1">
    <link rel="icon" href="/favicon.ico">
    <link rel="manifest" href="/manifest.json">
    <link rel="apple-touch-icon" href="/apple-touch-icon.png">
    <meta name="description" content="记录个人前端技术成长点滴">
    <meta name="theme-color" content="#3eaf7c">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    
    <link rel="preload" href="/assets/css/0.styles.9efbc543.css" as="style"><link rel="preload" href="/assets/js/app.e45e7f79.js" as="script"><link rel="preload" href="/assets/js/4.1dc261f9.js" as="script"><link rel="preload" href="/assets/js/41.33d492ee.js" as="script"><link rel="prefetch" href="/assets/js/10.910e44c4.js"><link rel="prefetch" href="/assets/js/11.3cb7fbc0.js"><link rel="prefetch" href="/assets/js/12.e84e4441.js"><link rel="prefetch" href="/assets/js/13.a20b1e0e.js"><link rel="prefetch" href="/assets/js/14.5bb81eb0.js"><link rel="prefetch" href="/assets/js/15.9ac9c7b5.js"><link rel="prefetch" href="/assets/js/16.e65d6e8b.js"><link rel="prefetch" href="/assets/js/17.3bcb37e9.js"><link rel="prefetch" href="/assets/js/18.238c27dc.js"><link rel="prefetch" href="/assets/js/19.0bf085fb.js"><link rel="prefetch" href="/assets/js/20.af32ca4b.js"><link rel="prefetch" href="/assets/js/21.d7d0a4bf.js"><link rel="prefetch" href="/assets/js/22.fb0bd41c.js"><link rel="prefetch" href="/assets/js/23.e40c513c.js"><link rel="prefetch" href="/assets/js/24.df877caa.js"><link rel="prefetch" href="/assets/js/25.ff943ee7.js"><link rel="prefetch" href="/assets/js/26.6975fab4.js"><link rel="prefetch" href="/assets/js/27.49355cdd.js"><link rel="prefetch" href="/assets/js/28.08ac8c0a.js"><link rel="prefetch" href="/assets/js/29.864244b6.js"><link rel="prefetch" href="/assets/js/30.9fde9cc1.js"><link rel="prefetch" href="/assets/js/31.04c169d6.js"><link rel="prefetch" href="/assets/js/32.57021f58.js"><link rel="prefetch" href="/assets/js/33.09502731.js"><link rel="prefetch" href="/assets/js/34.8a018286.js"><link rel="prefetch" href="/assets/js/35.097f93be.js"><link rel="prefetch" href="/assets/js/36.37ccdfeb.js"><link rel="prefetch" href="/assets/js/37.11976f3e.js"><link rel="prefetch" href="/assets/js/38.98243aad.js"><link rel="prefetch" href="/assets/js/39.a3c78447.js"><link rel="prefetch" href="/assets/js/40.7be6398d.js"><link rel="prefetch" href="/assets/js/42.f1c675e6.js"><link rel="prefetch" href="/assets/js/43.bbda546b.js"><link rel="prefetch" href="/assets/js/44.2dc401cd.js"><link rel="prefetch" href="/assets/js/45.33bd1151.js"><link rel="prefetch" href="/assets/js/46.b6b09012.js"><link rel="prefetch" href="/assets/js/47.55feb448.js"><link rel="prefetch" href="/assets/js/48.fc9dc909.js"><link rel="prefetch" href="/assets/js/49.fd6d33c4.js"><link rel="prefetch" href="/assets/js/5.ac586c16.js"><link rel="prefetch" href="/assets/js/50.8e33b7f9.js"><link rel="prefetch" href="/assets/js/51.fd278c0a.js"><link rel="prefetch" href="/assets/js/52.fbd66a3b.js"><link rel="prefetch" href="/assets/js/53.f829ac68.js"><link rel="prefetch" href="/assets/js/54.7c7e5ec8.js"><link rel="prefetch" href="/assets/js/55.42e87201.js"><link rel="prefetch" href="/assets/js/56.2301ffbd.js"><link rel="prefetch" href="/assets/js/57.6d5ed1a9.js"><link rel="prefetch" href="/assets/js/58.8dc29eab.js"><link rel="prefetch" href="/assets/js/59.722945c8.js"><link rel="prefetch" href="/assets/js/6.64876e20.js"><link rel="prefetch" href="/assets/js/60.c43354e4.js"><link rel="prefetch" href="/assets/js/61.b9d1ad1d.js"><link rel="prefetch" href="/assets/js/62.d61bfc10.js"><link rel="prefetch" href="/assets/js/63.d84a88b5.js"><link rel="prefetch" href="/assets/js/64.0f25c14d.js"><link rel="prefetch" href="/assets/js/7.d74ac93a.js"><link rel="prefetch" href="/assets/js/8.6c8e2482.js"><link rel="prefetch" href="/assets/js/9.085dc649.js"><link rel="prefetch" href="/assets/js/vendors~flowchart.4e554982.js"><link rel="prefetch" href="/assets/js/vendors~notification.4b668bb8.js">
    <link rel="stylesheet" href="/assets/css/0.styles.9efbc543.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><!----> <span class="site-name">Freeisms</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/my-docs/js/" class="nav-link">
  JavaScript
</a></div><div class="nav-item"><a href="/my-docs/design-pattern/" class="nav-link">
  设计模式
</a></div><div class="nav-item"><a href="/my-docs/leetcode/" class="nav-link router-link-active">
  LeetCode
</a></div><div class="nav-item"><a href="/my-docs/library/vue-juejin-comment.html" class="nav-link">
  开源库
</a></div><div class="nav-item"><a href="https://www.striveforus.com/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  博客
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <a href="https://github.com/Fengfengfeng-up/personal-docs" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/my-docs/js/" class="nav-link">
  JavaScript
</a></div><div class="nav-item"><a href="/my-docs/design-pattern/" class="nav-link">
  设计模式
</a></div><div class="nav-item"><a href="/my-docs/leetcode/" class="nav-link router-link-active">
  LeetCode
</a></div><div class="nav-item"><a href="/my-docs/library/vue-juejin-comment.html" class="nav-link">
  开源库
</a></div><div class="nav-item"><a href="https://www.striveforus.com/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  博客
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <a href="https://github.com/Fengfengfeng-up/personal-docs" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav>  <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>LeetCode</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/my-docs/leetcode/" aria-current="page" class="sidebar-link">写在前面</a></li><li><a href="/my-docs/leetcode/two-sum.html" class="sidebar-link">两数之和</a></li><li><a href="/my-docs/leetcode/add-two-numbers.html" class="sidebar-link">两数相加</a></li><li><a href="/my-docs/leetcode/longest-substring-without-repeating-characters.html" class="sidebar-link">无重复字符的最长子串</a></li><li><a href="/my-docs/leetcode/median-of-two-sorted-arrays.html" class="sidebar-link">寻找两个正序数组的中位数</a></li><li><a href="/my-docs/leetcode/longest-palindromic-substring.html" class="sidebar-link">最长回文子串</a></li><li><a href="/my-docs/leetcode/zigzag-conversion.html" class="sidebar-link">Z 字形变换</a></li><li><a href="/my-docs/leetcode/reverse-integer.html" class="sidebar-link">整数反转</a></li><li><a href="/my-docs/leetcode/string-to-integer-atoi.html" class="sidebar-link">字符串转换整数 (atoi)</a></li><li><a href="/my-docs/leetcode/palindrome-number.html" class="sidebar-link">回文数</a></li><li><a href="/my-docs/leetcode/regular-expression-matching.html" class="sidebar-link">正则表达式匹配</a></li><li><a href="/my-docs/leetcode/container-with-most-water.html" class="sidebar-link">盛最多水的容器</a></li><li><a href="/my-docs/leetcode/integer-to-roman.html" aria-current="page" class="active sidebar-link">整数转罗马数字</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/my-docs/leetcode/integer-to-roman.html#题目" class="sidebar-link">题目</a></li><li class="sidebar-sub-header"><a href="/my-docs/leetcode/integer-to-roman.html#解题思路" class="sidebar-link">解题思路</a></li><li class="sidebar-sub-header"><a href="/my-docs/leetcode/integer-to-roman.html#代码实现" class="sidebar-link">代码实现</a></li></ul></li><li><a href="/my-docs/leetcode/roman-to-integer.html" class="sidebar-link">罗马数字转整数</a></li><li><a href="/my-docs/leetcode/longest-common-prefix.html" class="sidebar-link">最长公共前缀</a></li><li><a href="/my-docs/leetcode/3sum.html" class="sidebar-link">三数之和</a></li><li><a href="/my-docs/leetcode/3sum-closest.html" class="sidebar-link">最接近的三数之和</a></li><li><a href="/my-docs/leetcode/letter-combinations-of-a-phone-number.html" class="sidebar-link">电话号码的字母组合</a></li><li><a href="/my-docs/leetcode/4sum.html" class="sidebar-link">四数之和</a></li><li><a href="/my-docs/leetcode/remove-nth-node-from-end-of-list.html" class="sidebar-link">删除链表的倒数第 N 个结点</a></li><li><a href="/my-docs/leetcode/valid-parentheses.html" class="sidebar-link">有效的括号</a></li><li><a href="/my-docs/leetcode/merge-two-sorted-lists.html" class="sidebar-link">合并两个有序链表</a></li><li><a href="/my-docs/leetcode/generate-parentheses.html" class="sidebar-link">括号生成</a></li><li><a href="/my-docs/leetcode/merge-k-sorted-lists.html" class="sidebar-link">合并K个升序链表</a></li><li><a href="/my-docs/leetcode/swap-nodes-in-pairs.html" class="sidebar-link">两两交换链表中的节点</a></li><li><a href="/my-docs/leetcode/reverse-nodes-in-k-group.html" class="sidebar-link">K 个一组翻转链表</a></li><li><a href="/my-docs/leetcode/remove-duplicates-from-sorted-array.html" class="sidebar-link">删除排序数组中的重复项</a></li><li><a href="/my-docs/leetcode/remove-element.html" class="sidebar-link">移除元素</a></li><li><a href="/my-docs/leetcode/implement-strstr.html" class="sidebar-link">实现 strStr()</a></li><li><a href="/my-docs/leetcode/divide-two-integers.html" class="sidebar-link">两数相除</a></li><li><a href="/my-docs/leetcode/substring-with-concatenation-of-all-words.html" class="sidebar-link">串联所有单词的子串</a></li><li><a href="/my-docs/leetcode/next-permutation.html" class="sidebar-link">下一个排列</a></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="整数转罗马数字"><a href="#整数转罗马数字" class="header-anchor">#</a> 整数转罗马数字</h1> <p>力扣🔗：<a href="https://leetcode-cn.com/problems/integer-to-roman" target="_blank" rel="noopener noreferrer">https://leetcode-cn.com/problems/integer-to-roman<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <h2 id="题目"><a href="#题目" class="header-anchor">#</a> 题目</h2> <p>罗马数字包含以下七种字符： <code>I</code>， <code>V</code>， <code>X</code>， <code>L</code>，<code>C</code>，<code>D</code> 和 <code>M</code>。</p> <div class="language- extra-class"><pre><code>字符          数值
I             1
V             5
X             10
L             50
C             100
D             500
M             1000
</code></pre></div><p>例如， 罗马数字 2 写做 <code>II</code> ，即为两个并列的 1。12 写做 <code>XII</code> ，即为 <code>X + II</code> 。 27 写做 <code>XXVII</code>, 即为 <code>XX + V + II</code>。</p> <p>通常情况下，罗马数字中小的数字在大的数字的右边。但也存在特例，例如 4 不写做 <code>IIII</code>，而是 <code>IV</code>。数字 1 在数字 5 的左边，所表示的数等于大数 5 减小数 1 得到的数值 4 。同样地，数字 9 表示为 <code>IX</code>。这个特殊的规则只适用于以下六种情况：</p> <ul><li><code>I</code> 可以放在 <code>V</code> (5) 和 <code>X</code> (10) 的左边，来表示 4 和 9。</li> <li><code>X</code> 可以放在 <code>L</code> (50) 和 <code>C</code> (100) 的左边，来表示 40 和 90。</li> <li><code>C</code> 可以放在 <code>D</code> (500) 和 <code>M</code> (1000) 的左边，来表示 400 和 900。</li></ul> <p>给定一个整数，将其转为罗马数字。输入确保在 1 到 3999 的范围内。</p> <p><strong>示例 1：</strong></p> <div class="language- extra-class"><pre><code>输入: 3
输出: &quot;III&quot;
</code></pre></div><p><strong>示例 2：</strong></p> <div class="language- extra-class"><pre><code>输入: 4
输出: &quot;IV&quot;
</code></pre></div><p><strong>示例 3：</strong></p> <div class="language- extra-class"><pre><code>输入: 58
输出: &quot;LVIII&quot;
解释: L = 50, V = 5, III = 3.
</code></pre></div><p><strong>示例 4：</strong></p> <div class="language- extra-class"><pre><code>输入: 9
输出: &quot;IX&quot;
</code></pre></div><p><strong>示例 5：</strong></p> <div class="language- extra-class"><pre><code>输入: 1994
输出: &quot;MCMXCIV&quot;
解释: M = 1000, CM = 900, XC = 90, IV = 4.
</code></pre></div><h2 id="解题思路"><a href="#解题思路" class="header-anchor">#</a> 解题思路</h2> <ul><li>首先通过 <code>10 ** ~~Math.log10(num)</code> 计算出 <code>num</code> 的数量级 <code>n</code>。</li> <li>然后从左至右依次循环通过 <code>~~(num / n)</code> 取出 <code>num</code> 中的每一位数字进行转换。</li> <li>每次循环结束时，更新 <code>num</code> 为 <code>num - m * n</code>（取出第一位数字），更新 <code>n</code> 为 <code>n / 10</code>（因每次取出一位数字，减少一个数量级）。</li></ul> <p>PS：😃 由于前面的题有类似的解题思路，所以这道题解起来很清晰很快！非宁静无以致远，日计不足，岁月有余，一点点积累吧！💪💪💪</p> <h2 id="代码实现"><a href="#代码实现" class="header-anchor">#</a> 代码实现</h2> <div class="language-js extra-class"><pre class="language-js"><code><span class="token comment">/**
 * @param {number} num
 * @return {string}
 */</span>
<span class="token keyword">function</span> <span class="token function">intToRoman</span><span class="token punctuation">(</span><span class="token parameter">num</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">const</span> map <span class="token operator">=</span> <span class="token punctuation">{</span> <span class="token number">1</span><span class="token operator">:</span> <span class="token string">'I'</span><span class="token punctuation">,</span> <span class="token number">5</span><span class="token operator">:</span> <span class="token string">'V'</span><span class="token punctuation">,</span> <span class="token number">10</span><span class="token operator">:</span> <span class="token string">'X'</span><span class="token punctuation">,</span> <span class="token number">50</span><span class="token operator">:</span> <span class="token string">'L'</span><span class="token punctuation">,</span> <span class="token number">100</span><span class="token operator">:</span> <span class="token string">'C'</span><span class="token punctuation">,</span> <span class="token number">500</span><span class="token operator">:</span> <span class="token string">'D'</span><span class="token punctuation">,</span> <span class="token number">1000</span><span class="token operator">:</span> <span class="token string">'M'</span> <span class="token punctuation">}</span>

  <span class="token keyword">let</span> n <span class="token operator">=</span> <span class="token number">10</span> <span class="token operator">**</span> <span class="token operator">~</span><span class="token operator">~</span>Math<span class="token punctuation">.</span><span class="token function">log10</span><span class="token punctuation">(</span>num<span class="token punctuation">)</span> <span class="token comment">// 当前的 num 的数量级</span>
  <span class="token keyword">let</span> m <span class="token comment">// 当前要转换的数字</span>
  <span class="token keyword">let</span> result <span class="token operator">=</span> <span class="token string">''</span>

  <span class="token keyword">do</span> <span class="token punctuation">{</span>
    m <span class="token operator">=</span> <span class="token operator">~</span><span class="token operator">~</span><span class="token punctuation">(</span>num <span class="token operator">/</span> n<span class="token punctuation">)</span> <span class="token comment">// 每次循环取 num 的第一位数字</span>

    <span class="token keyword">if</span> <span class="token punctuation">(</span>m <span class="token operator">&lt;</span> <span class="token number">5</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      result <span class="token operator">+=</span> m <span class="token operator">===</span> <span class="token number">4</span> <span class="token operator">?</span> map<span class="token punctuation">[</span>n<span class="token punctuation">]</span> <span class="token operator">+</span> map<span class="token punctuation">[</span>n <span class="token operator">*</span> <span class="token number">5</span><span class="token punctuation">]</span> <span class="token operator">:</span> map<span class="token punctuation">[</span>n<span class="token punctuation">]</span><span class="token punctuation">.</span><span class="token function">repeat</span><span class="token punctuation">(</span>m<span class="token punctuation">)</span>
    <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token keyword">if</span> <span class="token punctuation">(</span>m <span class="token operator">===</span> <span class="token number">5</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      result <span class="token operator">+=</span> map<span class="token punctuation">[</span>n <span class="token operator">*</span> <span class="token number">5</span><span class="token punctuation">]</span>
    <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
      result <span class="token operator">+=</span> m <span class="token operator">===</span> <span class="token number">9</span> <span class="token operator">?</span> map<span class="token punctuation">[</span>n<span class="token punctuation">]</span> <span class="token operator">+</span> map<span class="token punctuation">[</span>n <span class="token operator">*</span> <span class="token number">10</span><span class="token punctuation">]</span> <span class="token operator">:</span> map<span class="token punctuation">[</span><span class="token number">5</span> <span class="token operator">*</span> n<span class="token punctuation">]</span> <span class="token operator">+</span> map<span class="token punctuation">[</span>n<span class="token punctuation">]</span><span class="token punctuation">.</span><span class="token function">repeat</span><span class="token punctuation">(</span>m <span class="token operator">-</span> <span class="token number">5</span><span class="token punctuation">)</span>
    <span class="token punctuation">}</span>

    num <span class="token operator">-=</span> m <span class="token operator">*</span> n <span class="token comment">// 每次循环去除第一位数字</span>
    n <span class="token operator">/=</span> <span class="token number">10</span>
  <span class="token punctuation">}</span> <span class="token keyword">while</span> <span class="token punctuation">(</span>n <span class="token operator">&gt;=</span> <span class="token number">1</span> <span class="token operator">&amp;&amp;</span> num <span class="token operator">&gt;</span> <span class="token number">0</span><span class="token punctuation">)</span>

  <span class="token keyword">return</span> result
<span class="token punctuation">}</span>
</code></pre></div></div> <footer class="page-edit"><div class="edit-link"><a href="https://github.com/Fengfengfeng-up/personal-docs/edit/main/docs/my-docs/leetcode/integer-to-roman.md" target="_blank" rel="noopener noreferrer">在 GitHub 上编辑此页</a> <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></div> <div class="last-updated"><span class="prefix">上次更新:</span> <span class="time">1/19/2021, 6:25:16 PM</span></div></footer> <div class="page-nav"><p class="inner"><span class="prev">
      ←
      <a href="/my-docs/leetcode/container-with-most-water.html" class="prev">
        盛最多水的容器
      </a></span> <span class="next"><a href="/my-docs/leetcode/roman-to-integer.html">
        罗马数字转整数
      </a>
      →
    </span></p></div> </main></div><div class="global-ui"><!----></div></div>
    <script src="/assets/js/app.e45e7f79.js" defer></script><script src="/assets/js/4.1dc261f9.js" defer></script><script src="/assets/js/41.33d492ee.js" defer></script>
  </body>
</html>
